home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / OpenTptAppleTalk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-13  |  19.9 KB  |  738 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OpenTptAppleTalk.h
  3.  
  4.     Contains:    Public AppleTalk definitions
  5.  
  6.     Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  7.  
  8.  
  9. */
  10.  
  11. #ifndef __OPENTPTAPPLETALK__
  12. #define __OPENTPTAPPLETALK__
  13.  
  14. #ifndef REZ
  15.     #ifndef __OPENTRANSPORT__
  16.     #include <OpenTransport.h>
  17.     #endif
  18.     #if PRAGMA_ALIGN_SUPPORTED
  19.     #pragma options align=mac68k
  20.     #endif
  21. #endif
  22.  
  23. /*******************************************************************************
  24. ** Some prefixes for shared libraries
  25. ********************************************************************************/
  26.  
  27. #define kATalkVersion    "1.0"
  28. #define kATalkPrefix    "ot:atlk$"
  29. #define kATBinderID        "ot:atbd$"
  30.  
  31. /*******************************************************************************
  32. ** Module definitions
  33. ********************************************************************************/
  34. //
  35. // XTI Levels
  36. //
  37. #define ATK_DDP            'DDP '
  38. #define ATK_AARP        'AARP'
  39. #define ATK_ATP            'ATP '
  40. #define ATK_ADSP        'ADSP'
  41. #define ATK_ASP            'ASP '
  42. #define ATK_PAP            'PAP '
  43. #define ATK_NBP            'NBP '
  44. #define ATK_ZIP            'ZIP '
  45. //
  46. // Module Names
  47. //
  48. #define kDDPName        "ddp"
  49. #define    kATPName        "atp"
  50. #define kADSPName        "adsp"
  51. #define    kASPName        "asp"
  52. #define kPAPName        "pap"
  53. #define kNBPName        "nbp"
  54. #define kZIPName        "zip"
  55. #define kLTalkName        "ltlk"
  56. #define kLTalkAName        "ltlkA"
  57. #define kLTalkBName        "ltlkB"
  58.  
  59. /*******************************************************************************
  60. ** Protocol-specific Options
  61. **
  62. ** NOTE:
  63. ** All Protocols support OPT_CHECKSUM (Value is (unsigned long)T_YES/T_NO)
  64. ** ATP supports OPT_RETRYCNT (# Retries, 0 = try once) and
  65. **                OPT_INTERVAL (# Milliseconds to wait)
  66. ********************************************************************************/
  67.  
  68. #define DDP_OPT_CHECKSUM    OPT_CHECKSUM,
  69. #define DDP_OPT_SRCADDR        0x2101    /* DDP UnitDataReq Only - set src address    */
  70.                                     /* Value is DDPAddress                        */
  71.                                     
  72. #define ATP_OPT_REPLYCNT    0x2110    /* AppleTalk - ATP Resp Pkt Ct Type            */
  73.                                     /* Value is (unsigned long)  pkt count        */
  74. #define ATP_OPT_DATALEN        0x2111    /* AppleTalk - ATP Pkt Data Len Type        */
  75.                                     /* Value is (unsigned long) length            */
  76. #define ATP_OPT_RELTIMER    0x2112    /* AppleTalk - ATP Release Timer Type        */
  77.                                     /* Value is (unsigned long) timer            */
  78.                                     /* (See Inside AppleTalk, second edition    */
  79. #define ATP_OPT_TRANID        0x2113    /* Value is (unsigned long) Boolean            */
  80.                                     /* Used to request Transaction ID            */
  81.                                     /* Returned with Transaction ID on requests */
  82.  
  83. #define PAP_OPT_OPENRETRY    0x2120    /* AppleTalk - PAP OpenConn Retry count        */
  84.                                     /* Value is (unsigned long) T_YES/T_NO        */
  85.  
  86. /*******************************************************************************
  87. ** Protocol-specific events
  88. ********************************************************************************/
  89.  
  90. #ifndef REZ
  91.  
  92. enum
  93. {
  94.     kAppleTalkEvent                    = kPROTOCOLEVENT | 0x10000,
  95.  
  96.     T_GETMYZONECOMPLETE                = kAppleTalkEvent+1,
  97.     T_GETLOCALZONESCOMPLETE            = kAppleTalkEvent+2,
  98.     T_GETZONELISTCOMPLETE            = kAppleTalkEvent+3,
  99.     T_GETATALKINFOCOMPLETE            = kAppleTalkEvent+4,
  100.     
  101.     //
  102.     // If you send the IOCTL: OTIoctl(I_OTGetMiscellaneousEvents, 1),
  103.     // you will receive these events on your endpoint.
  104.     // NOTE: The endpoint does not need to be bound.
  105.     //
  106.     // No routers have been seen for a while.  If the cookie is NULL,
  107.     // all routers are gone.  Otherwise, there is still an ARA router
  108.     // hanging around being used, and only the local cable has been 
  109.     // timed out.
  110.     //
  111.     T_ATALKROUTERDOWNEVENT            = kAppleTalkEvent + 51,
  112.         //
  113.         // This indicates that all routers are offline
  114.         //
  115.         kAllATalkRoutersDown            = 0,
  116.         //
  117.         // This indicates that all local routers went offline, but
  118.         // an ARA router is still active
  119.         //
  120.         kLocalATalkRoutersDown            = -1L,
  121.         //
  122.         // This indicates that ARA was disconnected, do it's router went offline,
  123.         // and we have no local routers to fall back onto.
  124.         //
  125.         kARARouterDisconnected            = -2L,
  126.     //
  127.     // We didn't have a router, but now one has come up.
  128.     // Cookie is NULL for a normal router coming up, non-NULL
  129.     // for an ARA router coming on-line
  130.     //
  131.     T_ATALKROUTERUPEVENT            = kAppleTalkEvent + 52,
  132.         //
  133.         // We had no local routers, but an ARA router is now online.
  134.         //
  135.         kARARouterOnline                = -1L,
  136.         //
  137.         // We had no routers, but a local router is now online
  138.         //
  139.         kATalkRouterOnline                = 0,
  140.         //
  141.         // We have an ARA router, but now we've seen a local router as well
  142.         //
  143.         kLocalATalkRouterOnline             = -2L,
  144.     //
  145.     // A Zone name change was issued from the router, so our
  146.     // AppleTalk Zone has changed.
  147.     //
  148.     T_ATALKZONENAMECHANGEDEVENT        = kAppleTalkEvent + 53,
  149.     //
  150.     // An ARA connection was established (cookie != NULL),
  151.     // or was disconnected (cookie == NULL)
  152.     //
  153.     T_ATALKCONNECTIVITYCHANGEDEVENT    = kAppleTalkEvent + 54,
  154.     //
  155.     // A router has appeared, and our address is in the startup
  156.     // range.  Cookie is hi/lo of new cable range.
  157.     //
  158.     T_ATALKINTERNETAVAILABLEEVENT    = kAppleTalkEvent + 55,
  159.     //
  160.     // A router has appeared, and it's incompatible withour
  161.     // current address.  Cookie is hi/lo of new cable range.
  162.     //
  163.     T_ATALKCABLERANGECHANGEDEVENT    = kAppleTalkEvent + 56
  164.     //
  165.     // A bad router has appeared/disappeared on our network.
  166.     //
  167. };
  168.  
  169. #define IsAppleTalkEvent(x)            ((x) & 0xffff0000) == kAppleTalkEvent)
  170.  
  171. /*******************************************************************************
  172. ** Protocol-specific constants
  173. ********************************************************************************/
  174.  
  175. enum
  176. {
  177.     /*    -------------------------------------------------------------------------
  178.         ECHO
  179.         ------------------------------------------------------------------------- */
  180.  
  181.     kECHO_TSDU                = 585,        // Max. # of data bytes.
  182.  
  183.     /*    -------------------------------------------------------------------------
  184.         NBP
  185.         ------------------------------------------------------------------------- */
  186.  
  187.     kNBPMaxNameLength        = 32,
  188.     kNBPMaxTypeLength        = 32,
  189.     kNBPMaxZoneLength        = 32,
  190.     kNBPSlushLength            = 9,    // Extra space for @, : and a few escape chars
  191.     kNBPMaxEntityLength        = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + 3),
  192.     kNBPEntityBufferSize    = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + kNBPSlushLength),
  193.     kNBPWildCard            = 0x3D,        // NBP name and type match anything '='
  194.     kNBPImbeddedWildCard    = 0xC5,        // NBP name and type match some '≈'
  195.     kNBPDefaultZone            = 0x2A,        // NBP default zone '*'
  196.  
  197.     /*    -------------------------------------------------------------------------
  198.         ZIP
  199.         ------------------------------------------------------------------------- */
  200.     
  201.     kZIPMaxZoneLength        = kNBPMaxZoneLength,
  202.     
  203.     /*    -------------------------------------------------------------------------
  204.         Address-related values
  205.         ------------------------------------------------------------------------- */
  206.         
  207.     kDDPAddressLength        = 8,        // value to use in netbuf.len field
  208.                                         // Maximum length of AppleTalk address
  209.     kNBPAddressLength        = kNBPEntityBufferSize,
  210.     kAppleTalkAddressLength    = kDDPAddressLength + kNBPEntityBufferSize
  211. };
  212.  
  213. #define OTCopyDDPAddress(addr, dest)                \
  214.     {                                                \
  215.         ((UInt32*)(dest))[0] = ((UInt32*)(addr))[0];    \
  216.         ((UInt32*)(dest))[1] = ((UInt32*)(addr))[1];    \
  217.     }
  218.  
  219. /*******************************************************************************
  220. ** CLASS TAppleTalkServices
  221. ********************************************************************************/
  222.  
  223. #if !OTKERNEL
  224.  
  225. #ifndef __cplusplus
  226.     typedef void*    ATSvcRef;
  227. #else
  228.     class TAppleTalkServices;
  229.     typedef TAppleTalkServices*    ATSvcRef;
  230. #endif
  231.  
  232. #define kDefaultAppleTalkServicesPath    ((OTConfiguration*)-3)
  233.  
  234. #ifdef __cplusplus
  235. extern "C" {
  236. #endif
  237.  
  238. extern pascal OSStatus    OTAsyncOpenAppleTalkServices(OTConfiguration* cfig, OTOpenFlags flags,
  239.                                                      OTNotifyProcPtr, void* contextPtr);            
  240. extern pascal ATSvcRef    OTOpenAppleTalkServices(OTConfiguration* cfig, OTOpenFlags flags,
  241.                                                 OSStatus* err);
  242.     //
  243.     // Get the zone associated with the ATSvcRef
  244.     //
  245. extern pascal OSStatus    OTATalkGetMyZone(ATSvcRef ref, TNetbuf* zone);
  246.     //
  247.     // Get the list of available zones associated with the local cable
  248.     // of the ATSvcRef
  249.     //
  250. extern pascal OSStatus    OTATalkGetLocalZones(ATSvcRef ref, TNetbuf* zones);
  251.     //
  252.     // Get the list of all zones on the internet specified by the ATSvcRef
  253.     //
  254. extern pascal OSStatus    OTATalkGetZoneList(ATSvcRef ref, TNetbuf* zones);
  255.     //
  256.     // Stores an AppleTalkInfo structure into the TNetbuf (see later in this file)
  257.     //
  258. extern pascal OSStatus    OTATalkGetInfo(ATSvcRef ref, TNetbuf* info);
  259.  
  260. #ifdef __cplusplus
  261. }
  262.  
  263. class TAppleTalkServices : public TProvider
  264. {
  265.     public:
  266.             OSStatus    GetMyZone(TNetbuf* zone)         { return OTATalkGetMyZone(this, zone); }
  267.             OSStatus    GetLocalZones(TNetbuf* zones)    { return OTATalkGetLocalZones(this, zones); }
  268.             OSStatus    GetZoneList(TNetbuf* zones)        { return OTATalkGetZoneList(this, zones); }
  269.             OSStatus    GetInfo(TNetbuf* info)            { return OTATalkGetInfo(this, info); }
  270. };
  271.  
  272. #endif    /* _cplus */
  273. #endif    /* !OTKERNEL */
  274.  
  275. /*    -------------------------------------------------------------------------
  276.     AppleTalk Addressing
  277.     
  278.     The NBPEntity structure is used to manipulate NBP names without regard
  279.     to issues of what kind of "special" characters are in the name.
  280.     
  281.     When stored as an address in an NBPAddress or DDPNBPAddress, they are 
  282.     stored as a character string, which is currently just ASCII, but in the
  283.     future may be UniChar, or some other internationalizable scripting set.
  284.     The string following an NBPAddress or DDPNBPAddress is intended to be
  285.     suitable for showing to users, whereas NBPEntity is not.
  286.     WARNING: NBPAddress and DDPNBPAddress structures do not "know" the length
  287.     of the address.  That must have been obtained as part of a Lookup or
  288.     ResolveAddress call.
  289.     ------------------------------------------------------------------------- */
  290.  
  291.     typedef struct DDPAddress        DDPAddress;
  292.     typedef struct NBPAddress        NBPAddress;
  293.     typedef struct DDPNBPAddress    DDPNBPAddress;
  294.     
  295.     struct NBPEntity
  296.     {
  297.         UInt8    fEntity[kNBPMaxEntityLength];
  298.     };
  299.     
  300.     typedef struct NBPEntity    NBPEntity;
  301.  
  302.     /*    ---------------------------------------------------------------------
  303.         These are some utility routines for dealing with NBP and DDP addresses. 
  304.         --------------------------------------------------------------------- */
  305.     
  306.     #ifdef __cplusplus
  307.     extern "C" {
  308.     #endif
  309.     //
  310.     // Functions to initialize the various AppleTalk Address types
  311.     //
  312.     extern pascal void        OTInitDDPAddress(DDPAddress* addr, UInt16 net, UInt8 node,
  313.                                              UInt8 socket, UInt8 ddpType);
  314.     extern pascal size_t    OTInitNBPAddress(NBPAddress* addr, const char* name);
  315.     extern pascal size_t    OTInitDDPNBPAddress(DDPNBPAddress* addr, const char* name,
  316.                                                 UInt16 net, UInt8 node, UInt8 socket,
  317.                                                 UInt8 ddpType);
  318.         //
  319.         // Compare 2 DDP addresses for equality
  320.         //
  321.     extern pascal Boolean    OTCompareDDPAddresses(const DDPAddress* addr1, const DDPAddress* addr2);
  322.         //
  323.         // Init an NBPEntity to a NULL name
  324.         //
  325.     extern pascal void        OTInitNBPEntity(NBPEntity* entity);
  326.         //
  327.         // Get the length an NBPEntity would have when stored as an address
  328.         // 
  329.     extern pascal size_t    OTGetNBPEntityLengthAsAddress(const NBPEntity* entity);
  330.         //
  331.         // Store an NBPEntity into an address buffer
  332.         //
  333.     extern pascal size_t    OTSetAddressFromNBPEntity(UInt8* nameBuf, const NBPEntity* entity);
  334.         //
  335.         // Create an address buffer from a string (use -1 for len to use strlen)
  336.         //
  337.     extern pascal size_t    OTSetAddressFromNBPString(UInt8* addrBuf, const char* name, SInt32 len);
  338.         //
  339.         // Create an NBPEntity from an address buffer. False is returned if
  340.         //   the address was truncated.
  341.         //
  342.     extern pascal Boolean    OTSetNBPEntityFromAddress(NBPEntity* entity, const UInt8* addrBuf,
  343.                                                       size_t len);
  344.         //
  345.         // Routines to set a piece of an NBP entity from a character string
  346.         //
  347.     extern pascal Boolean    OTSetNBPName(NBPEntity* entity, const char* name);
  348.     extern pascal Boolean    OTSetNBPType(NBPEntity* entity, const char* typeVal);
  349.     extern pascal Boolean    OTSetNBPZone(NBPEntity* entity, const char* zone);
  350.         //
  351.         // Routines to extract pieces of an NBP entity
  352.         //
  353.     extern pascal void        OTExtractNBPName(const NBPEntity* entity, char* name);
  354.     extern pascal void        OTExtractNBPType(const NBPEntity* entity, char* typeVal);
  355.     extern pascal void        OTExtractNBPZone(const NBPEntity* entity, char* zone);
  356.                                                 
  357.     #ifdef __cplusplus
  358.     }
  359.     #endif
  360.  
  361.     enum
  362.     {
  363.         AF_ATALK_FAMILY    = 0x0100,
  364.         AF_ATALK_DDP    = AF_ATALK_FAMILY,
  365.         AF_ATALK_DDPNBP    = AF_ATALK_FAMILY + 1,
  366.         AF_ATALK_NBP    = AF_ATALK_FAMILY + 2,
  367.         AF_ATALK_MNODE    = AF_ATALK_FAMILY + 3
  368.     };
  369.  
  370. struct DDPAddress
  371. {
  372.     OTAddressType    fAddressType;        // One of the enums above
  373.     UInt16            fNetwork;
  374.     UInt8            fNodeID;
  375.     UInt8            fSocket;
  376.     UInt8            fDDPType;
  377.     UInt8            fPad;
  378. #ifndef __cplusplus
  379.  
  380. };
  381.  
  382. #else
  383.  
  384.     public:
  385.                 void            Init(const DDPAddress&);
  386.                 void            Init(UInt16 net, UInt8 node, UInt8 socket);
  387.                 void            Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  388.  
  389.                 void            SetSocket(UInt8);
  390.                 void            SetType(UInt8);
  391.                 void            SetNode(UInt8);
  392.                 void            SetNetwork(UInt16);
  393.             
  394.                 size_t            GetAddressLength() const;
  395.                 OTAddressType    GetAddressType() const;
  396.                 UInt8            GetSocket() const;
  397.                 UInt8            GetType() const;
  398.                 UInt8            GetNode() const;
  399.                 UInt16            GetNetwork() const;
  400.             
  401.                 Boolean            operator==(const DDPAddress&) const;
  402.                 Boolean            operator!=(const DDPAddress&) const;
  403.                 void            operator=(const DDPAddress&);
  404. };
  405.  
  406. /*
  407.  *    Inline methods for DDPAddress
  408.  */
  409.  
  410.     inline void DDPAddress::operator=(const DDPAddress& addr)
  411.     {
  412.         *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  413.         *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  414.     }
  415.     
  416.     inline Boolean DDPAddress::operator==(const DDPAddress& addr) const
  417.     {
  418.         return OTCompareDDPAddresses(&addr, this);
  419.     }
  420.     
  421.     inline Boolean DDPAddress::operator!=(const DDPAddress& addr) const
  422.     {
  423.         return !OTCompareDDPAddresses(&addr, this);
  424.     }
  425.     
  426.     inline void DDPAddress::SetSocket(UInt8 socket)
  427.     {
  428.         fSocket = socket;
  429.     }
  430.     
  431.     inline void DDPAddress::SetNode(UInt8 node)
  432.     {
  433.         fNodeID = node;
  434.     }
  435.     
  436.     inline void DDPAddress::SetType(UInt8 type)
  437.     {
  438.         fDDPType = type;
  439.     }
  440.     
  441.     inline void DDPAddress::SetNetwork(UInt16 net)
  442.     {
  443.         fNetwork = net;
  444.     }
  445.     
  446.     inline size_t DDPAddress::GetAddressLength() const
  447.     {
  448.         return kDDPAddressLength;
  449.     }
  450.     
  451.     inline OTAddressType DDPAddress::GetAddressType() const
  452.     {
  453.         return fAddressType;
  454.     }
  455.     
  456.     inline UInt8 DDPAddress::GetSocket() const
  457.     {
  458.         return fSocket;
  459.     }
  460.     
  461.     inline UInt8 DDPAddress::GetNode() const
  462.     {
  463.         return fNodeID;
  464.     }
  465.     
  466.     inline UInt8 DDPAddress::GetType() const
  467.     {
  468.         return fDDPType;
  469.     }
  470.     
  471.     inline UInt16 DDPAddress::GetNetwork() const
  472.     {
  473.         return fNetwork;
  474.     }
  475.     
  476.     inline void  DDPAddress::Init(UInt16 net, UInt8 node,
  477.                                   UInt8 socket)
  478.     {
  479.         fAddressType = AF_ATALK_DDP;
  480.         SetNetwork(net);
  481.         SetNode(node);
  482.         SetSocket(socket);
  483.         SetType(0);
  484.     }
  485.     
  486.     inline void  DDPAddress::Init(UInt16 net, UInt8 node,
  487.                                   UInt8 socket, UInt8 type)
  488.     {
  489.         fAddressType = AF_ATALK_DDP;
  490.         SetNetwork(net);
  491.         SetNode(node);
  492.         SetSocket(socket);
  493.         SetType(type);
  494.     }
  495.     
  496.     inline void DDPAddress::Init(const DDPAddress& addr)
  497.     {
  498.         *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  499.         *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  500.     }
  501.     
  502. #endif    /* __cplusplus */
  503.  
  504.  
  505. struct NBPAddress
  506. {
  507.     OTAddressType    fAddressType;        // One of the enums above
  508.     UInt8            fNBPNameBuffer[kNBPEntityBufferSize];
  509. #ifndef __cplusplus
  510.  
  511. };
  512.  
  513. #else
  514.  
  515.     public:
  516.                 size_t            Init();
  517.                 size_t            Init(const NBPEntity&);
  518.                 size_t            Init(const char*);
  519.                 size_t            Init(const char*, size_t len);
  520.                 Boolean            ExtractEntity(NBPEntity&, size_t len);
  521.             
  522.                 OTAddressType    GetAddressType() const;
  523. };
  524.  
  525. /*
  526.  *    Inline methods for NBPAddress
  527.  */
  528.  
  529.     inline size_t NBPAddress::Init()
  530.     {
  531.         fAddressType = AF_ATALK_NBP;
  532.         return sizeof(OTAddressType);
  533.     }
  534.     
  535.     inline size_t NBPAddress::Init(const NBPEntity& addr)
  536.     {
  537.         fAddressType = AF_ATALK_NBP;
  538.         return sizeof(OTAddressType) + OTSetAddressFromNBPEntity(fNBPNameBuffer, &addr);
  539.     }
  540.     
  541.     inline size_t NBPAddress::Init(const char* name)
  542.     {
  543.         fAddressType = AF_ATALK_NBP;
  544.         return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, -1);
  545.     }
  546.     
  547.     inline size_t NBPAddress::Init(const char* name, size_t len)
  548.     {
  549.         fAddressType = AF_ATALK_NBP;
  550.         return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len);
  551.     }
  552.     
  553.     inline Boolean NBPAddress::ExtractEntity(NBPEntity& entity, size_t len)
  554.     {
  555.         return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  556.     }
  557.         
  558.     inline OTAddressType NBPAddress::GetAddressType() const
  559.     {
  560.         return fAddressType;
  561.     }
  562.     
  563. #endif    /* __cplusplus */
  564.  
  565. struct DDPNBPAddress
  566. {
  567.     OTAddressType    fAddressType;        // One of the enums above
  568.     UInt16            fNetwork;
  569.     UInt8            fNodeID;
  570.     UInt8            fSocket;
  571.     UInt8            fDDPType;
  572.     UInt8            fPad;
  573.     UInt8            fNBPNameBuffer[kNBPEntityBufferSize];
  574.  
  575. #ifndef __cplusplus
  576.  
  577. };
  578.  
  579. #else
  580.  
  581.     public:
  582.                 void            Init(const DDPAddress&);
  583.                 void            Init(UInt16 net, UInt8 node, UInt8 socket);
  584.                 void            Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  585.  
  586.                 void            SetSocket(UInt8);
  587.                 void            SetType(UInt8);
  588.                 void            SetNode(UInt8);
  589.                 void            SetNetwork(UInt16);
  590.                 
  591.                 OTAddressType    GetAddressType() const;
  592.                 UInt8            GetSocket() const;
  593.                 UInt8            GetType() const;
  594.                 UInt8            GetNode() const;
  595.                 UInt16            GetNetwork() const;
  596.                 
  597.                 Boolean            ExtractEntity(NBPEntity&, size_t len);
  598.                 size_t            SetNBPEntity(const NBPEntity&);
  599.                 size_t            SetNBPEntity(const char*);
  600.                 size_t            SetNBPEntity(const char*, size_t len);
  601.                 
  602.                 Boolean            operator==(const DDPAddress&) const;
  603. };
  604.  
  605. /*
  606.  *    Inline methods for DDPNBPAddress
  607.  */
  608.     inline Boolean DDPNBPAddress::operator==(const DDPAddress& addr) const
  609.     {
  610.         return OTCompareDDPAddresses((const DDPAddress*)this, &addr);
  611.     }
  612.     
  613.     inline void DDPNBPAddress::SetSocket(UInt8 socket)
  614.     {
  615.         fSocket = socket;
  616.     }
  617.     
  618.     inline void DDPNBPAddress::SetNode(UInt8 node)
  619.     {
  620.         fNodeID = node;
  621.     }
  622.     
  623.     inline void DDPNBPAddress::SetType(UInt8 type)
  624.     {
  625.         fDDPType = type;
  626.     }
  627.     
  628.     inline void DDPNBPAddress::SetNetwork(UInt16 net)
  629.     {
  630.         fNetwork = net;
  631.     }
  632.     
  633.     inline OTAddressType DDPNBPAddress::GetAddressType() const
  634.     {
  635.         return fAddressType;
  636.     }
  637.     
  638.     inline UInt8 DDPNBPAddress::GetSocket() const
  639.     {
  640.         return fSocket;
  641.     }
  642.     
  643.     inline UInt8 DDPNBPAddress::GetNode() const
  644.     {
  645.         return fNodeID;
  646.     }
  647.     
  648.     inline UInt8 DDPNBPAddress::GetType() const
  649.     {
  650.         return fDDPType;
  651.     }
  652.     
  653.     inline UInt16 DDPNBPAddress::GetNetwork() const
  654.     {
  655.         return fNetwork;
  656.     }
  657.     
  658.     inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  659.                                     UInt8 socket)
  660.     {
  661.         fAddressType = AF_ATALK_DDPNBP;
  662.         SetNetwork(net);
  663.         SetNode(node);
  664.         SetSocket(socket);
  665.         SetType(0);
  666.     }
  667.     
  668.     inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  669.                                     UInt8 socket, UInt8 type)
  670.     {
  671.         fAddressType = AF_ATALK_DDPNBP;
  672.         SetNetwork(net);
  673.         SetNode(node);
  674.         SetSocket(socket);
  675.         SetType(type);
  676.     }
  677.     
  678.     inline void DDPNBPAddress::Init(const DDPAddress& addr)
  679.     {
  680.         fAddressType = AF_ATALK_DDPNBP;
  681.         SetNetwork(addr.GetNetwork());
  682.         SetNode(addr.GetNode());
  683.         SetSocket(addr.GetSocket());
  684.         SetType(addr.GetType());
  685.         fNBPNameBuffer[0] = 0;
  686.     }
  687.     
  688.     inline size_t DDPNBPAddress::SetNBPEntity(const NBPEntity& entity)
  689.     {
  690.         return OTSetAddressFromNBPEntity(fNBPNameBuffer, &entity) + kDDPAddressLength;
  691.     }
  692.     
  693.     inline size_t DDPNBPAddress::SetNBPEntity(const char* name)
  694.     {
  695.         return OTSetAddressFromNBPString(fNBPNameBuffer, name, -1) + kDDPAddressLength;
  696.     }
  697.     
  698.     inline size_t DDPNBPAddress::SetNBPEntity(const char* name, size_t len)
  699.     {
  700.         return OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len) + kDDPAddressLength;
  701.     }
  702.     
  703.     inline Boolean DDPNBPAddress::ExtractEntity(NBPEntity& entity, size_t len)
  704.     {
  705.         return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  706.     }
  707.  
  708. #endif    /* __cplusplus */
  709.  
  710. /*    -------------------------------------------------------------------------
  711.         AppleTalkInfo - filled out by the OTGetATalkInfo function
  712.     ------------------------------------------------------------------------- */
  713.  
  714. struct AppleTalkInfo
  715. {
  716.     DDPAddress    fOurAddress;        // Our DDP address (network # & node)
  717.     DDPAddress    fRouterAddress;        // The address of a router on our cable
  718.     UInt16        fCableRange[2];        // The current cable range
  719.     UInt16        fFlags;                // See below
  720. };
  721.  
  722. //
  723. // For the fFlags field in AppleTalkInfo
  724. //
  725. enum
  726. {
  727.     kATalkInfoIsExtended    = 0x0001,    // This is an extended (phase 2) network
  728.     kATalkInfoHasRouter        = 0x0002,    // This cable has a router
  729.     kATalkInfoOneZone        = 0x0004    // This cable has only one zone
  730. };
  731.  
  732. #if PRAGMA_ALIGN_SUPPORTED
  733. #pragma options align=reset
  734. #endif
  735.  
  736. #endif    /*    REZ    */
  737. #endif    /*  __OPENTPTAPPLETALK__ */
  738.